#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
//
// Created by lenovo on 25-1-4.
//

class Solution
{
public:
    static vector<int> findDisappearedNumbers(vector<int>& nums)
    {
        size_t n = nums.size();
        vector<int> rv;

        // 标记出现过的数字
        for (int i = 0; i < n; ++i) {
            int index = abs(nums[i]) - 1;
            if (index < n && nums[index] > 0) {
                nums[index] = -nums[index];
            }
        }

        // 找到未出现的数字
        for (int j = 0; j < n; ++j) {
            if (nums[j] > 0) {
                rv.push_back(j + 1);
            }
        }

        return rv;
    }
};
